import Vue from 'vue'
import router from '@/router/index'
import config from '@/config/config'
import VueResource from 'vue-resource'
import {setCookie, getCookie} from '@/util/user'
import {thirdLogin} from '@/util/thirdpartyLogin'
Vue.use(VueResource);

export function aliLogin(code) {
  Vue.http.post(config.baseUrl + '/alipay/alipayOauth', {
    'code': code,
  }, {
    headers: {},
    credientials: true,
    emulateJSON: true
  }).then(function (response) {
      if (response.data.code == 200) {
        // alert('ok')
        var userId = response.data.data.userId
        var avatar = response.data.data.avatar
        // alert(response.data.data.userId)
        // alert(response.data.data.avatar)
        thirdLogin(userId,avatar,'ali')
      } else {
      layer.open({
        content: data.msg,
        btn: ['知道了']
      })
    }
  });
}
